package com.alisoft.nano.seda.notification;

import javax.management.Notification;

import com.alisoft.nano.seda.Event;

public class EventMachineNotification<T> extends Notification {

	private static final long serialVersionUID = 2638173739346218180L;	

	public static final String ACCEPTED = "ali.seda.eventmachine.accepted";
	public static final String ERROR = "ali.seda.eventmachine.error";
	public static final String COMPLETED = "ali.seda.eventmachine.completed";
	
	private EventMachineNotification(String type, Event<T> event) {
		super(type, event, 0);
	}

	@SuppressWarnings("unchecked")
	public Event<T> getEvent() {
		return (Event<T>) this.getSource();
	}
	
	public static <T> EventMachineNotification<T> newError(Event<T> event) {
		return new EventMachineNotification<T>(ERROR, event);
	}
	
	public static <T> EventMachineNotification<T> newCompleted(Event<T> event) {
		return new EventMachineNotification<T>(COMPLETED, event);
	}
	
	public static <T> EventMachineNotification<T> newAccepted(Event<T> event) {
		return new EventMachineNotification<T>(ACCEPTED, event);
	}
}
